﻿@page
@model XZTZ.UMP.WEB.Pages.Change.ShowTableModel
@{
    Layout = null;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
        }

        .leftbar {
            position: fixed;
            right: 10px;
            top: 100px;
        }

        .TableTemp {
            width: 100%;
            margin: 0 0 1em;
            border: 0;
        }
    </style>
</head>
<body>
    <iframe class="TableTemp" id="TableTemp" name="TableTemp" src="ReportVision1/ExcelDesignSum" frameborder="0"></iframe>
    <div class="leftbar">
        <input type="button" value="下载pif" onclick="downloadPDF()" />
    </div>
</body>
</html>
<script src="https://localhost:5001/js/JQ.js"></script>
<script type="text/javascript">
        function setIframeHeight(iframe) {
        if (iframe) {
            var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
            if (iframeWin.document.body) {
            iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
        }
    }
};

    window.onload = function () {
            setIframeHeight(document.getElementById('TableTemp'));
        };
    //function downloadPDF() {
    //    $.ajax({
    //        type: 'POST',
    //        url: 'https://localhost:5001/Change/ReportVision1/ExcelDesignSum',
    //        data: { htmlCode: "test" },
    //        success: function () {
    //            alert(1);
    //        },
    //        });
    //    }
    function downloadPDF() {
        var params = new Array();
        var str = document.getElementById('TableTemp').contentWindow.document.documentElement.outerHTML;
        params.push({ name: "htmlCode", value: str });
        Post("/Change/ShowTable?handler=Down", params);
    }

    function Post(URL, PARAMTERS) {
        //创建form表单
        var temp_form = document.createElement("form");
        temp_form.action = URL;
        //如需打开新窗口，form的target属性要设置为'_blank'
        temp_form.target = "_self";
        temp_form.method = "post";
        temp_form.style.display = "none";
        //添加参数
        for (var item in PARAMTERS) {
            var opt = document.createElement("textarea");
            opt.name = PARAMTERS[item].name;
            opt.value = PARAMTERS[item].value;
            temp_form.appendChild(opt);
        }
        document.body.appendChild(temp_form);
        //提交数据
        temp_form.submit();
    }
</script>